# -*- tcl -*-

test pt-peg-import-1.0 {import text, wrong#args} -setup {
    pt::peg::import I
} -body {
    I import text
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::pt::peg::import::Snit_hmethodimport_text type selfns win self text ?format?"}

test pt-peg-import-1.1 {import text, wrong#args} -setup {
    pt::peg::import I
} -body {
    I import text T F XX
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::pt::peg::import::Snit_hmethodimport_text type selfns win self text ?format?"}

test pt-peg-import-2.0 {import file, wrong#args} -setup {
    pt::peg::import I
} -body {
    I import file
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::pt::peg::import::Snit_hmethodimport_file type selfns win self path ?format?"}

test pt-peg-import-2.1 {import file, wrong#args} -setup {
    pt::peg::import I
} -body {
    I import file P F XXX
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::pt::peg::import::Snit_hmethodimport_file type selfns win self path ?format?"}

test pt-peg-import-3.0 {import object text, wrong#args} -setup {
    pt::peg::import I
} -body {
    I import object text
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::pt::peg::import::Snit_hmethodimport_object_text type selfns win self obj text ?format?"}

test pt-peg-import-3.1 {import object text, wrong#args} -setup {
    pt::peg::import I
} -body {
    I import object text O
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::pt::peg::import::Snit_hmethodimport_object_text type selfns win self obj text ?format?"}

test pt-peg-import-3.2 {import object text, wrong#args} -setup {
    pt::peg::import I
} -body {
    I import object text O T F XXX
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::pt::peg::import::Snit_hmethodimport_object_text type selfns win self obj text ?format?"}

test pt-peg-import-4.0 {import object file, wrong#args} -setup {
    pt::peg::import I
} -body {
    I import object file
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::pt::peg::import::Snit_hmethodimport_object_file type selfns win self obj path ?format?"}

test pt-peg-import-4.1 {import object file, wrong#args} -setup {
    pt::peg::import I
} -body {
    I import object file O
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::pt::peg::import::Snit_hmethodimport_object_file type selfns win self obj path ?format?"}

test pt-peg-import-4.2 {import object file, wrong#args} -setup {
    pt::peg::import I
} -body {
    I import object file O P F XXX
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::pt::peg::import::Snit_hmethodimport_object_file type selfns win self obj path ?format?"}

# config unset - accepts any number of arguments.

# -------------------------------------------------------------------------
## `include` component, provided via fileutil::paths, search path for includes

test pt-peg-import-5.0 {include paths, wrong#args} -setup {
    pt::peg::import I
} -body {
    I include paths X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodpaths type selfns win self"}

test pt-peg-import-6.0 {include clear, wrong#args} -setup {
    pt::peg::import I
} -body {
    I include clear X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodclear type selfns win self"}

test pt-peg-import-7.0 {include add, wrong#args} -setup {
    pt::peg::import I
} -body {
    I include add
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodadd type selfns win self path"}

test pt-peg-import-7.1 {include add, wrong#args} -setup {
    pt::peg::import I
} -body {
    I include add P X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodadd type selfns win self path"}

test pt-peg-import-8.0 {include remove, wrong#args} -setup {
    pt::peg::import I
} -body {
    I include remove
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodremove type selfns win self path"}

test pt-peg-import-8.1 {include remove, wrong#args} -setup {
    pt::peg::import I
} -body {
    I include remove P X
} -cleanup {
    I destroy
} -returnCodes error -result {wrong # args: should be "::fileutil::paths::Snit_methodremove type selfns win self path"}

# -------------------------------------------------------------------------

test pt-peg-import9.0 {include paths, empty} -setup {
    pt::peg::import I
} -body {
    I include paths
} -cleanup {
    I destroy
} -result {}

test pt-peg-import9.1 {include paths, several paths, order} -setup {
    pt::peg::import I
    I include add first
    I include add second
} -body {
    I include paths
} -cleanup {
    I destroy
} -result {first second}

test pt-peg-import-10.0 {include add, unknown} -setup {
    pt::peg::import I
} -body {
    I include add A
    I include paths
} -cleanup {
    I destroy
} -result A

test pt-peg-import-10.1 {include add, already known} -setup {
    pt::peg::import I
} -body {
    I include add A
    I include add A
    I include paths
} -cleanup {
    I destroy
} -result A

test pt-peg-import-11.0 {include remove, unknown} -setup {
    pt::peg::import I
} -body {
    I include add A
    I include remove B
    I include paths
} -cleanup {
    I destroy
} -result A

test pt-peg-import-11.1 {include remove, known} -setup {
    pt::peg::import I
} -body {
    I include add A
    I include remove A
    I include paths
} -cleanup {
    I destroy
} -result {}

test pt-peg-import-12.0 {include clear} -setup {
    pt::peg::import I
} -body {
    I include add A
    I include add B
    I include clear
    I include paths
} -cleanup {
    I destroy
} -result {}

# Tests for the various import plugins, i.e. for their use from the
# import manager. Numbering starts at 20.
# -------------------------------------------------------------------------

source [localPath tests/pt_peg_import_plugins.tests]

# -------------------------------------------------------------------------
return
